<?php

class Visits_Plugin_Menus {

  public function onMenuInitialize_UserProfileVisits($row)
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    $subject = Engine_Api::_()->core()->getSubject();
    
    // check auth
    if( !Engine_Api::_()->authorization()->isAllowed('visits', $viewer, 'view') ) {
      return false;
    }
    
    if( $subject->isSelf($viewer) && $viewer->getIdentity()) {
      return array(
        'icon' => 'application/modules/User/externals/images/links/search.png',
        'route' => 'visits_visits',
        'params' => array(
          'module' => 'visits',
          'controller' => 'index',
          'action' => 'index',
        )
      );   
    }

    return false;
  }
    
}